home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 19 / Mac Magazin and MacEasy Magazine CD - Issue 19.iso / Datenbanken & Hypercard / File Toolkit for 4D 1.0 ƒ / FTk Short Manual (1⁄2) < prev    next >
Text File  |  1996-01-29  |  21KB  |  422 lines

  1. File Toolkit for 4D® vs 1.0 : Short Manual (1/2)
  2.  
  3. Welcome to File Toolkit for 4D®, an extension package for those of you who are serious about handling Finder objects within 4D applications.
  4.  
  5. After reading this short manual and trying the package, please do register your copy : for a low $99, you'll get rid of the welcome screen and get a full Acrobat™ documentation with hypertext links and code examples. You may reach us at ftk@dig.cie.fr for technical information or sales@dig.cie.fr for any commercial questions.
  6.  
  7. Clic the “Order Form (US)” button on the welcome screen and you will be asked for basic informations needed to register your copy, then print or save the order form and send it to :
  8.  
  9. DIG
  10. File Toolkit for 4D
  11. Z.I. La Pimpine
  12. 33360 LATRESNE
  13. FRANCE
  14.  
  15. Fax : (33) 56 20 78 86
  16.  
  17. Internet : sales@dig.cie.fr
  18. CompuServe : 72300,3135
  19. FirstClass BBS : (33) 1 48 87 84 62 or (33) 56 20 79 01
  20.  
  21. ToC
  22.  
  23. Due to SimpleText restrictions, this short manual is divided into 2 parts.
  24.  
  25. Topics of FTk Short Manual 1/2 :
  26.  
  27. Conventions
  28. Installing File Toolkit for 4D®
  29. Protection and demo version
  30. How to serialize your copy
  31. Operation
  32. Package structure
  33. Tools set
  34. FSSpec set
  35. Finder set 
  36. File Info set
  37.  
  38. Topics of FTk Short Manual 2/2 :
  39.  
  40. Conventions
  41. Folders set
  42. Volumes set
  43. Aliases set
  44. Standard File set
  45. File I/O set
  46. Encapsulation set
  47. Applications set
  48. Progress bars set
  49. Error codes
  50.  
  51.  
  52. Conventions
  53.  
  54. Use SimpleText or any other text editor with style viewing features to read and print this document. All typographic enhancements will be lost otherwise, resulting in a less readable text.
  55.  
  56. Parameters parsing conventions :
  57.  
  58. fi 4D to File Toolkit for 4D® 
  59. ‹ File Toolkit for 4D® to 4D
  60. € 4D to File Toolkit for 4D®, then modified by File Toolkit for 4D®
  61. ø Result returned by File Toolkit for 4D® (0 or error code)
  62.  
  63. Functions description is set in Geneva 10. Functions syntax and code examples are set in Monaco 9. Parameter parsing directions (fi ‹ € ø) are set in Symbol 9. All are standard system fonts. If one of these fonts is missing from your system, the result may look a bit jagged.
  64.  
  65.  
  66. Installing File Toolkit for 4D®
  67.  
  68. File Toolkit for 4D® is a 4th Dimension extension package. To include its functions to your current 4D application, drop the File Toolkit for 4D® file in the Mac4DX folder of your 4D structure folder. Create a new Mac4DX folder if none is present at installation.
  69.  
  70. Please note : File Toolkit for 4D® cannot be installed with External Mover Plus. File Toolkit for 4D® will only run under System 7.x and 4th Dimension® vs 3.2 (4D Server® 1.2) or above.
  71.  
  72. File Toolkit for 4D® is optimized for Power Macintosh®.
  73.  
  74.  
  75. Protection and demo version
  76.  
  77. You may and should feel free to copy the demo version of File Toolkit for 4D® provided you include all the files of the original distribution archive.
  78.  
  79. While your copy of File Toolkit for 4D® is not registered, a welcome screen appears when you launch your 4D database application. This non serialized mode is the package's demonstration mode.
  80.  
  81. In demo mode, the package is fully functional, but the welcome screen will appear every hour, and you will have to wait longer and longer for the Ok button to activate...
  82.  
  83. No-hassle license : you only have to register one copy of File Toolkit for 4D® per developer, regardless of the number of machines or database applications you're working on.
  84.  
  85. You will be asked to enter the registration code for File Toolkit for 4D® for each one of your 4D structures. If you have registered your copy of File Toolkit for 4D® and then copy it to another database (i.e. an other Mac4DX folder) the package will then reverse to demo mode until you reenter your serial code.
  86.  
  87.  
  88. How to serialize your copy
  89.  
  90. - When buying File Toolkit for 4D® from DIG, you receive a complete documentation and a license number.
  91. - Launch your 4D database and click the Serialize button in the welcome screen.
  92. - Enter your name, the name of your company and your license number as provided in the registration form.
  93. - If the registration information is not valid, File Toolkit for 4D® will stay in demo mode.
  94.  
  95.  
  96. Operation
  97.  
  98. File Toolkit for 4D® makes use of FSSpecs (File System Specifications) to reference Finder objects. A file, a folder, an alias, a volume, all these objects may be referenced by their FSSpec. Functions are provided in the FSSpec set for the purpose of converting pathnames to FSSpecs and back.
  99.  
  100. Using FSSpecs rather than pathnames offers several advantages :
  101.  
  102. - A FSSpec may refer to any object with a pathname longer than 255 characters.
  103. - FSSpecs all have the same size (80 bytes) regardless of the location of the object referenced by the FSSpec.
  104. - FSSpecs are the data structure internally used by the File Manager of the Mac operating system.
  105. - Within File Toolkit for 4D®, FSSpecs are much faster than pathnames, for they don't have to be decoded.
  106. - A pathname is only needed once at the start of a file operation, FSSpecs may be used afterwards.
  107.  
  108. FSSpecs are not persistent between two restarts of the computer. Neither are pathnames, if for example any part of the hierarchy is renamed or moved. When looking for persistence, try aliases, which may be handled through the package's alias set of functions.
  109.  
  110. For File Toolkit for 4D® (as for the File Manager in MacOS) a volume is a regular folder, all functions which work with FSSpecs to folders also work with FSSpecs to volumes.
  111.  
  112. Due to 4D operation, you may only parse 4D record fields from 4D to the package. If a package function returns a value, it must first be stored in a variable before being copied to a record field. This is the same for array elements.
  113.  
  114. OSErr values returned by most functions are either negative (File Manager system errors) or positive (File Toolkit for 4D® internal errors).
  115.  
  116. String parameters to functions may vary in length :
  117. - 80 characters for FSSpecs.
  118. - 32 characters for file and folder names.
  119. - 4 characters for file signatures: types or creators.
  120.  
  121.  
  122. Package structure
  123.  
  124. All of the package's functions are divided into several sets. Functions of the first two sets are often used in conjunction with functions of the remaining sets.
  125.  
  126. - Tools set : set and test package options, convert File Manager data to 4D types
  127. - FSSpec set : FSSpecs to pathnames and back, direct FSSpec handling
  128. - Finder set : perform usual Finder tricks
  129. - File Info set : get to know and fix everything about file informations
  130. - Folder set : manage folders every way you can
  131. - Volume set : get a list of volumes, mount, unmount or eject them
  132. - Alias set : create, store and resolve Finder aliases
  133. - Standard file set : access the File Manager's standard open and save dialogs
  134. - File I/O set : read and write bytes from selected files
  135. - Encapsulation set : from whole files to 4D objects and back
  136. - Application set : 3.. 2.. 1.. Launch !
  137. - Progress bar set : show your progress in style
  138.  
  139.  
  140. Tools set
  141.  
  142. Use calls to the Tools set of functions to fix the package options, and convert some data to types usable in 4D.
  143.  
  144. ft_IsSerialized (String ‹ Name ; String ‹ Company) ø Int Serialized
  145.  
  146. This function returns the operating status of File Toolkit for 4D®.
  147.  
  148. If Serialized = 1, the package was serialized, Name and Company hold the text entered in the registration dialog.
  149. If Serialized # 1, the package is operating in demo mode.
  150.  
  151. ft_GetOptions (Int ‹ TraceOnError ; Int ‹ CopyBufferSize ; Int ‹ ProgressBar ; Int ‹ DeleteLocked ; Int ‹ inFrench)
  152.  
  153. This command gets the package operating options. Use it with ft_SetOptions to change a single option without affecting the others.
  154.  
  155. If TraceOnError = 1, and a function returns an error code different from noErr (0), 4D jumps into trace mode after the instruction line where the package was called (defaults to 0).
  156.  
  157. If CopyBufferSize # 0, a buffer of the specified size (in bytes) is allocated to the file copy functions.
  158. If CopyBufferSize = 0, the default buffer of 256 Kb = 262144 bytes is used. To optimize performance, set the buffer size to a multiple of 512 bytes (262144 = 512*512).
  159.  
  160. If ProgressBar = 1, a progress bar window is displayed during long operations (file copy and delete). Defaults to 1. 
  161.  
  162. If DeleteLocked = 1, locked files are trashed without returning an error code, similar to pressing the option key while emptying the trash. Defaults to 0.
  163.  
  164. If inFrench = 1, dialogs and error messages are displayed in French.
  165. If inFrench = 0, dialogs and error messages are displayed in English.
  166.  
  167. ft_SetOptions (Int fi TraceOnError ; Int fi CopyBufferSize ; Int fi ProgressBar ; Int fi DeleteLocked ; Int fi inFrench)
  168.  
  169. This command sets the package operating options. Modifications are effective immediately. If an asynchronous file copy is in progress when the modification occurs, the current copy does not take the modification into account. inFrench is the only persistent option, all other options must be set at startup.
  170.  
  171. Refer to ft_GetOptions for a parameter description.
  172.  
  173. ft_GetErrorText (Int fi ErrorNum ; String ‹ ErrorText)
  174.  
  175. This command returns in the ErrorText string the description error number ErrorNum. Texts are only supplied for positive error codes (specific to File Toolkit for 4D®). System errors are not handled by ft_GetErrorText.
  176.  
  177. ft_BitTest (Long fi BitStream ; Int fi BitNum) ø Int BitState
  178.  
  179. BitState = 1 if bit BitNum is set to 1 in BitStream.
  180. BitState = 0 if bit BitNum is set to 0 in BitStream.
  181. Call this function when testing status bits in finderFlags (see ft_GetInfo).
  182.  
  183. ft_BitSet (Long fi BitStream ; Int fi BitNum ; Int fi BitState)
  184.  
  185. Sets bit BitNum to BitState (1 or 0) in BitStream. 
  186. Use this command to set status bits in finderFlags (see ft_SetInfo).
  187.  
  188. ft_Date2Long (Date fi theDate ; Time fi theTime) ø Long Secs
  189.  
  190. Converts theDate and theTime to a long integer (Secs) matching the number of past seconds since January 1st 1904. Call this function when setting the creation/modification/backup dates of a file/folder (see ft_SetInfo).
  191.  
  192. To work around the famous 4D time handling bug®, use it as shown below :
  193.  
  194. C_TIME (theTime)
  195. C_DATE (theDate)
  196. C_LONGINT (Secs)
  197. Secs := ft_Date2Long (theDate; 0 + theTime)
  198.  
  199. ft_Long2Date (Long fi Secs ; Date ‹ theDate) ø Time theTime
  200.  
  201. Converts the number of seconds in Secs to theDate and theTime in 4D format.
  202. Call this function when retrieving the creation/modification/backup dates of a file/folder (see ft_GetInfo).
  203.  
  204. To work around the famous 4D time handling bug®, use it as shown below :
  205.  
  206. C_TIME (theTime)
  207. C_DATE (theDate)
  208. C_LONGINT (Secs)
  209. theTime := †00:00:00† + ft_Long2Date (Secs;theDate)
  210.  
  211.  
  212. FSSpec set
  213.  
  214. Use calls to the FSSpec set of functions to convert pathnames to FSSpec and back, or for direct FSSpec handling.
  215.  
  216. ft_Path2FSSpec (Text fi FullPath ; String ‹ TargetSpec) ø Int OSErr
  217.  
  218. Converts a full path name to a FSSpec. The pathname is not limited to 255 characters, allowing to parse a complex hierarchy exceeding this limit. If FullPath refers to a folder or volume, it must end with a colon character “:”.
  219.  
  220. FSSpec referencing non-existent files/folders allow you to create them : an error code (-43) is returned, yet the FSSpec is valid.
  221.  
  222. ft_FSSpec2Path (String fi TargetSpec ; Text ‹ FullPath) ø Int OSErr
  223.  
  224. Converts an FSSpec to a full pathname.
  225. If TargetSpec refers to a folder or a volume, FullPath ends with a colon character “:”.
  226.  
  227. ft_FSSpecParent (String fi TargetSpec ; String ‹ ParentSpec) ø Int OSErr
  228.  
  229. ParentSpec is a FSSpec referencing the parent folder of TargetSpec. For instance, if TargetSpec refers to "myHD:myFolder:myFolder2:", ParentSpec will refer to "myHD:myFolder:"
  230.  
  231. ft_FSSpecName (String fi TargetSpec ; String ‹ TargetName ; Int ‹ IsFolder) ø Int OSErr
  232.  
  233. Returns in TargetName the name of the object referenced by TargetSpec (file, folder, volume).
  234. IsFolder = 1 if TargetSpec refers to a folder or volume.
  235.  
  236. For instance, if TargetSpec refers to "myHD:myFolder:myFolder2:", TargetName = "myFolder2" and IsFolder = 1.
  237.  
  238. ft_Add2FSSpec (String fi TargetSpec ; String fi Name ; String ‹ newSpec) ø Int OSErr
  239.  
  240. Adds a name to a folder FSSpec, to get a FSSpec referencing an item within the folder. TargetSpec must refer to a folder or volume. Name must be inserted between colons, (e.g. ":foo:") to add a folder to the TargetSpec FSSpec. A -43 error code is returned if Name does not exist, still newSpec is valid.
  241.  
  242. ft_SameFSSpec (String fi aSpec ; String ‹ anotherSpec ; Int ‹ sameFSSpec) ø Int OSErr
  243.  
  244. Compares two FSSpec. sameFSSpec = 1 if aSpec and anotherSpec both refer to the same object.
  245.  
  246. ft_GetFSSpeIcon (String fi TargetSpec ; Int fi LargeIcon ; Pict ‹ Icon) ø Int OSErr
  247.  
  248. Returns in Icon the finder icon of the object referenced by TargetSpec. 
  249. If LargeIcon = 1, the icon is a 32 x 32 bitmap (large icon).
  250. If LargeIcon # 1, the icon is a 16 x 16 bitmap (small icon).
  251.  
  252.  
  253. Finder set 
  254.  
  255. Use calls to the Finder set to create, copy, move, delete and rename files and folders.
  256.  
  257. ft_Create (String € TargetSpec ; String fi Name ; String fi Type ; String fi Creator) ø Int OSErr
  258.  
  259. Creates a Name file using Type and Creator as signature in the folder referenced by TargetSpec.
  260. If TargetSpec refers to a non-existent file, Name is ignored and TargetSpec is used for creation.
  261.  
  262. A FSSpec referencing the new file is returned in TargetSpec.
  263. If a file already exists at this location, a -48 error code is returned.
  264.  
  265. ft_NewFolder (String € TargetSpec ; String fi Name) ø Int OSErr
  266.  
  267. Creates a Name folder in the folder referenced by TargetSpec.
  268. If TargetSpec refers to a non-existent folder, Name is ignored and TargetSpec is used for creation.
  269.  
  270. A FSSpec referencing the new folder is returned in TargetSpec.
  271. If a folder already exists at this location, a -48 error code is returned.
  272.  
  273. ft_Delete (String fi TargetSpec) ø Int OSErr
  274.  
  275. Deletes the object referenced by TargetSpec. If TargetSpec refers to a folder, its content is also deleted. If TargetSpec refers to an alias, the alias is deleted, but its target is left untouched.
  276.  
  277. If one of the deleted objects is locked, a -45 error code is returned, unless the DeleteLocked option is set in the package (see ft_SetOptions).
  278.  
  279. ft_AsyncDelete (String fi TargetSpec ; String fi ProcName ; Long ‹ ProcessID ; Long ‹ Refnum) ø Int OSErr
  280.  
  281. Deletes the object referenced by TargetSpec. If TargetSpec refers to a folder, its content is also deleted. If TargetSpec refers to an alias, the alias is deleted, but its target is left untouched.
  282.  
  283. Objects are deleted in the background, in a separate process, the id of which is returned in ProcessID. When the operation is completed, the ProcName command procedure is called by the ProcessID process. The ProcName procedure gets an OSErr integer parameter holding the operation error code, and a Refnum long integer that uniquely identifies the process where the delete action was performed.
  284.  
  285. For instance :
  286.  
  287. ...
  288.  $Err := ft_AsyncDelete (mySpec;"completion";◊deleteProcessID;◊deleteRefNum)
  289. ...
  290.  
  291. Procedure “completion”:
  292.  
  293. C_INTEGER($1)
  294. C_LONGINT($2)
  295.  
  296. $Err:=$1
  297.  
  298. if ((Current Process = ◊deleteProcessID) & ($2 = ◊deleteRefNum))
  299.  if ($Err=0)
  300.   `do something here
  301.  else
  302.   ALERT ("an error occurred : "+String($Err))
  303.  end if
  304. end if
  305.  
  306. ft_Move (String fi SourceSpec ; String € DestSpec ; String fi NewName) ø Int OSErr
  307.  
  308. Moves a file or a folder referenced by SourceSpec to the folder referenced by DestSpec on the same volume. Objects cannot be moved to a different volume, use ft_Copy and ft_Delete instead.
  309.  
  310. If NewName # "", the object is renamed after being moved. A -48 error code is returned if the object was moved but could not be renamed because NewName was already used by an other item in DestSpec.
  311.  
  312. DestSpec gets the new FSSpec to the moved object.
  313.  
  314. ft_Copy (String fi SourceSpec ; String € DestSpec ; String fi NewName) ø Int OSErr
  315.  
  316. Copies the object referenced by SourceSpec to the folder referenced by DestSpec with all its content.
  317. DestSpec gets the new FSSpec to the copied object.
  318.  
  319. If NewName # "", the object is renamed after being copied.
  320.  
  321. If both the source and destination objects are located on the same AppleShare volume, copy is optimized so that the machine issuing the copy instruction is not used during transfer.
  322.  
  323. ft_AsyncCopy (String fi SourceSpec ; String fi DestSpec ; String fi NewName ;
  324.  String fi ProcName ; Long ‹ ProcessID ; Long ‹ Refnum) ø Int OSErr
  325.  
  326. Copies the object referenced by SourceSpec to the folder referenced by DestSpec with all its content.
  327. This function does not return a FSSpec to the copied object, use ft_FSSpecName and ft_Add2FSSpec instead.
  328.  
  329. If NewName # "", the object is renamed after being copied.
  330.  
  331. If both the source and destination objects are located on the same AppleShare volume, copy is optimized so that the machine issuing the copy instruction is not used during transfer.
  332.  
  333. Objects are copied in the background, in a separate process, the id of which is returned in ProcessID. When the operation is completed, the ProcName command procedure is called by the ProcessID process. The ProcName procedure gets an OSErr integer parameter holding the operation error code, and a Refnum long integer that uniquely identifies the process where the copy was performed.
  334.  
  335. For instance :
  336.  
  337. ...
  338. $Err := ft_AsyncCopy (mySrcSpec;myDestSpec;"";"completion";◊copyProcessID;◊copyRefNum)
  339.  
  340. if($Err=0)
  341.  $Err := ft_FSSpecName(mySrcSpec;sourceName;isFolder)
  342.  if($Err=0)
  343.   if(isFolder=1)
  344.    sourceName := ":"+sourceName+":"
  345.   end if
  346.  
  347.   $Err := ft_Add2FSSpec(myDestSpec;sourceName;myCopySpec)
  348.   ` here myCopySpec is a FSSpec to the copied object
  349.  end if
  350. end if
  351. ...
  352.  
  353. Procedure “completion”:
  354.  
  355. C_INTEGER($1)
  356. C_LONGINT($2)
  357.  
  358. $Err:=$1
  359.  
  360. if ((Current Process = ◊copyProcessID) & ($2 = ◊copyRefNum))
  361.  if($Err=0)
  362.  ` Do something here
  363.  else
  364.  ALERT ("an error occurred : "+String($Err))
  365.  end if
  366. end if
  367.  
  368. ft_Rename (String € TargetSpec ; String fi NewName) ø Int OSErr
  369.  
  370. Renames the object referenced by TargetSpec to NewName.
  371. A FSSpec to the renamed object is returned in TargetSpec.
  372.  
  373.  
  374. File Info set
  375.  
  376. Calls to the File Info set will let you handle all the information visible in the Informations option of the Finder's File menu.
  377.  
  378. ft_GetFileSign (String fi TargetSpec ; String ‹ Type ; String ‹ Creator) ø Int OSErr
  379.  
  380. Returns type and creator information for the file referenced by TargetSpec.
  381.  
  382. ft_SetFileSign (String fi TargetSpec ; String fi Type ; String fi Creator) ø Int OSErr
  383.  
  384. Sets type and creator information for the file referenced by TargetSpec.
  385. If Type or Creator = "", the information is left untouched.
  386.  
  387. ft_GetInfo (String fi TargetSpec ; String ‹ FileType ; String ‹ FileCreator ; Long ‹ CreationDate ; Long ‹ ModifDate ; Long ‹ BackupDate ; Int ‹ FinderFlags ; Int ‹ Locked ; Long ‹ DataForkSize ; Long ‹ ResForkSize) ø Int OSErr
  388.  
  389. Returns finder informations for the file referenced by TargetSpec. For folder and volume information, see ft_FolderInfo and ft_GetVolInfo.
  390. Locked = 1 if file is locked.
  391.  
  392. To convert dates and times to 4D format, use ft_Long2Date.
  393. To test separate bits of FinderFlags, use ft_BitTest.
  394. DataForkSize and ResForkSize are returned in bytes. Add them to get the total file size.
  395.  
  396. ft_SetInfo (String fi TargetSpec ; String fi FileType ; String fi FileCreator ; Long fi CreationDate ; Long fi ModifDate ; Long fi BackupDate ; Int fi FinderFlags ; Int fi Locked) ø Int OSErr
  397.  
  398. Sets finder informations for the file referenced by TargetSpec. To set folder and volume information, see ft_SetFolderInfo.
  399.  
  400. If Type or Creator = "", the information is left untouched.
  401. Use the ft_Date2Long function to convert dates and times from 4D format.
  402. Use the ft_BitSet function to set separate bits in FinderFlags.
  403.  
  404. ft_GetFileVers (String fi TargetSpec ; Int fi VersNum ; String ‹ LongStringVers ; String ‹ ShortStringVers ; Int ‹ CountryCode) ø Int OSErr
  405.  
  406. Gets informations for the VersNum ‘vers’ resource in the file referenced by TargetSpec. LongStringVers returns text, whereas ShortStringVers returns the short version number. CountryCode, well, is pretty obvious isn't it ? Use ResEdit to take a good look at a 'vers' resource before using this function.
  407.  
  408. ft_SetFileVers (String fi TargetSpec ; Int fi VersNum ; String fi LongStringVers ; String fi ShortStringVers ; Int fi CountryCode) ø Int OSErr
  409.  
  410. Sets informations for the VersNum ‘vers’ resource in the file referenced by TargetSpec, if it already holds one. ft_SetFileVers does not create a new ‘vers’ resource.
  411.  
  412. You may call ft_SetFileVers to modify the 'vers' resource of the current 4D structure file.
  413.  
  414. Modifications to other open 4D files (Proc.Ext, data files, files in the Mac4DX folder) may result in file corruption or system errors. The only safely modifiable active 4D document is the structure file.
  415.  
  416. See ft_GetFileVers for parameters list, and use ft_IsBusy to check a file prior to modification.
  417.  
  418.  
  419. File Toolkit for 4D® is a trademark of DIG SARL.
  420. 4th Dimension and 4D Server are registered trademarks of ACI SA.
  421. Acrobat, Apple, Macintosh, Power Macintosh, MacOS, Finder, AppleShare, Novell, Netware, PowerTalk are trademarks of their respective owners.
  422.